var app = angular.module("kaffipad", ['kaffipad.services','kaffipad.settings', 'ngCookies']).
config(function($routeProvider){
    $routeProvider.
    when('/info',{
        templateUrl:'partials/info.html',
        controller:AboutCtrl
    }).
    when('/login',{
        templateUrl:'partials/login.html',
        controller:LoginCtrl
    }).
    when('/settings',{
        templateUrl:'partials/settings.html',
        controller:SettingsCtrl}
    ).
    otherwise({
        redirectTo:'/home',
        templateUrl:'partials/home.html', 
        controller:HomeCtrl
    });
}).run(function(){
    console.log("Running");
}).directive('user', function() {
    return {
        restrict: 'E',
        replace: true,
        transclude: true,
        template: 
        '<div class="user">' +
        '   <img src="{{user.stampUser.values.image}}" />' +
        '   <div class="userinfo">' +
        '       <div class="username" data-email="{{user.stampUser.values.email}}">{{user.stampUser.values.name}}</div>' +
        '       <div class="consumption">' + 
        '           <img data-ng-hide="user.stampUser.values.locked" class="consumptionImage" src="img/coffee.png" />' +
        '           <span data-ng-hide="user.stampUser.values.locked" >{{user.consumption.length}}</span>' +
        '           <span data-ng-hide="user.stampUser.values.locked" title="The number of unsynchronized consumptions" data-ng-show="user.getUnsynchedConsumption().length!=0" class="vague">({{user.getUnsynchedConsumption().length}})</span>' +
        '           <img data-ng-show="user.stampUser.values.locked" class="userLock" src="img/users/lock.png" />' +
        '       </div>' +
        '   </div>' +
        '   <div data-ng-click="gotoUnlockUser(user)" class="smallLockOverlay" data-ng-show="user.stampUser.values.locked" />' +
        '</div>',
        link: function(scope, element, attrs) {
            $(element).draggable({
                revert: true,
                containment: "#containerDiv",
                scroll: false,
                distance: 5
            });
        }
    }
});
